<%--
  Created by IntelliJ IDEA.
  User: ljh
  Date: 2024/10/12
  Time: 19:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ include file="partials/_start.jsp" %>

<main class="container mt-3">
    <p>
        <a href="<%= request.getContextPath() %>/add-user">添加用户</a>
    </p>
    <form action="users" method="get" class="d-inline-block">
        <input type="text" name="name" value="${searchString}"/>
        <button type="submit">搜素</button>
    </form>
    <a href="users" class="ps-3">清除搜索条件</a>
    <hr>
    <table class="table table-hover">
        <tr>
            <th>No.</th>
            <th>ID</th>
            <th>Name</th>
            <th>Email</th>
            <th>Action</th>
        </tr>
        <c:forEach items="${users}" var="user" varStatus="status">
            <tr>
                <td>${status.count}</td>
                <td>${user.id}</td>
                <td>${user.name}</td>
                <td>${user.email}</td>
                <td>
                    <a href="delete-user?id=${user.id}" class="pe-3">删除</a>
                    <a href="update-user?id=${user.id}">修改</a>
                </td>
            </tr>
        </c:forEach>
    </table>
    <nav>
        <ul class="pagination">
            <li class="page-item">
                <a class="page-link" href="?page=${page - 1}${searchString != null ? "&name=".concat(searchString) : ""}">Previous</a>
            </li>
            <%--<li class="page-item disabled">
                <a class="page-link" href="#">1</a>
            </li>--%>
            <li class="page-item">
                <a class="page-link" href="?page=${page + 1}${searchString != null ? "&name=".concat(searchString) : ""}">Next</a>
            </li>
        </ul>
    </nav>
</main>

<%@ include file="partials/_end.jsp" %>